import { ExecutionContext, createParamDecorator } from "@nestjs/common";

export enum UserEnum {
  "userId" = "userId",
  "username" = "username",
  "nick_name" = "nick_name",
  "dept_id" = "dept_id",
  "dept_name" = "dept_name",
}

// 设置在参数中，获取哪些用户信息
export const User = createParamDecorator((data: UserEnum, ctx: ExecutionContext) => {
  const request = ctx.switchToHttp().getRequest();
  const user = request.user;
  return data ? user && user.userId : user;
});
